/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package util.apache_commons;

import java.io.UnsupportedEncodingException;
import org.apache.commons.lang3.StringEscapeUtils;

/**
 *
 * @author rdelacruz
 */
public class StringEscapeUtil {
  
    public static String codificarHTML(String texto) throws UnsupportedEncodingException {
        return codificarHTML(texto,true);
    }
    
    public static String codificarHTML(String texto, boolean trim) throws UnsupportedEncodingException {
        if(texto==null)
            return "";
        return StringEscapeUtils.escapeHtml4(trim ? texto.trim() : texto);
    }
}
